<template>
    <el-container v-loading="loading" class="home">
        <el-header style="text-align: right; font-size: 12px">
            <header-view></header-view>
        </el-header>
        <el-container>
            <el-aside class="aside" width="200px">
                <aside-view></aside-view>
            </el-aside>

            <el-main>
                <!-- 二级试图 => 配置在 / 路由下  -->
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
// import bus from "@/utils/EventBus"
import HeaderView from "./Header";
import AsideView from "./Aside";
import {  mapGetters, mapActions } from 'vuex';

export default {
    name: "HomeView",
    data() {
       
        const item = {
            date: '2016-05-02',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1518 弄'
        };
        return {
            loading:false,
            tableData: Array(20).fill(item)
        }
    },
    methods: {
        ...mapActions([ "getAndUpdateAuthorityInfo"]),
    },
    computed: {
        ...mapGetters(["isLogin"]),
    },
    created() {
        console.log("主页组件重新初始化");
        // this.getAndUpdateAuthorityInfo();  // 用户进入主页面时 => 根据localStorage更新vuex  

        // bus.$on("loadingStart",()=>{
        //     console.log("加载开始");
        //     this.loading = true;
        // })
        // bus.$on("loadingFinish",()=>{
        //     console.log("加载结束");
        //     setTimeout(() => {
        //         this.loading = false;
        //     }, 100);
        // })
    },
    mounted() {
        // 判断是否登录  => 没有登录 => 去登录
        // if (!this.isLogin) {
        //     this.$router.push({
        //         path: "/login",
        //         query: { ReturnUrl: this.$route.fullPath }
        //     })
        //     this.$message({
        //         message: "您还没有登录,请登录!",
        //         type: "warning",
        //     })
        // }

        // bus.$on("loadingStart",()=>{
        //     this.loading = true;
        // })
        // bus.$on("loadingFinish",()=>{
        //     this.loading = false;
        // })
        // setTimeout(()=>{
        //     bus.$emit("loadingFinish");
        // },2000)

        // bus.$emit("loadingFinish");

    },
    components:{
        HeaderView,
        AsideView
    }
}
</script>

<style  scoped>
.home {
    height: 100%;
}

.loginNick {
    margin-right: 10px;
}

.aside {
    border-right: solid 1px #e6e6e6;
}

.aside .el-menu {
    border-right: 0;
}

.el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
}

.el-aside {
    color: #333;
}
</style>